Ext.define('appmod.view.resources.menu.Form', {
    extend: 'Ext.form.Panel',
	alias: [
		'widget.menu-form',
		'widget.menuresourceform'
	],
	requires: [
		'Ext.ux.TreePicker'
	],		
	bodyPadding: 10,

	constructor: function (config) {
		
		if (config.fieldStores) {
			this.fieldStores = config.fieldStores;
		}
        this.callParent(arguments);
     },	

    initComponent: function() {
        var me = this;

		var emptyStore = Ext.create('Ext.data.TreeStore',
		{
			root:
			{
				text: '根菜单',
				id: 'root',
				expanded: true,
				children:
				[
				]
			},
			folderSort: false
		});
		
		var dsParent = emptyStore;
		var dsModAllSel = null;
		if (me.fieldStores != null) {
			if (me.fieldStores['dsParent']) {
				dsParent = me.fieldStores['dsParent'];
			}
			if (me.fieldStores['dsModAllSel']) {
				dsModAllSel = me.fieldStores['dsModAllSel'];
			}

		}

        Ext.applyIf(me, {
            items: [
                {
                    xtype: 'textfield',
                    fieldLabel: '菜单编码',
					name: 'code',
					labelWidth: 80,
                    anchor: '95%'
                },
                {
                    xtype: 'hiddenfield',
                    name: 'idSysRes',
                    anchor: '100%'
                },
                {
                    xtype: 'textfield',
                    fieldLabel: '菜单名称',
					name : 'name',
					labelWidth: 80,
                    anchor: '95%'
                },
                {
                    xtype: 'combobox',
                    fieldLabel: '所属模块',
					editable : false,
					displayField:'name',
					valueField:'id',
					store : dsModAllSel,
					name:'moduleId',
					queryMode : 'local',					
					labelWidth: 80,
                    anchor: '50%'
                },
                {
                    xtype: 'fieldset',
                    layout: {
                        type: 'hbox'
                    },
					defaults: {
						 anchor: '100%',
						 margins:'0 5 0 0'
					},
                    title: '父 级',
					height : 60,
                    items: [
		                {
		                    xtype: 'treepicker',
		                    fieldLabel: '选择菜单名',
							store : dsParent,
							displayField:'text',
							name:'parentId',
		                    anchor: '50%'
		                }					
                    ]
                },
                {
                    xtype: 'radiogroup',
                    fieldLabel: '访问设定',
                    anchor: '95%',
                    items: [
                        {
                            xtype: 'radiofield',
                            boxLabel: '允许',
                            checked: true,
							inputValue:0,
							name:'disabled'
                        },
                        {
                            xtype: 'radiofield',
							inputValue:1,
							name:'disabled',
                            boxLabel: '禁用'
							
                        }
                    ]
                },
				{
		            fieldLabel: '同级排序',
					labelWidth: 80,
		            name: 'sortNum',
		            xtype: 'numberfield',
					minValue : 0,
					maxValue: 100000
		        }				
            ]
        });

        me.callParent(arguments);
    }
});